import GM from 'gm'
import { mkdirSync } from 'fs'

const targetPath = 'assets/images/babylon/sprite'

mkdirSync(targetPath, {recursive: true})

/** 每张图片800*800 */
const images = [
  'assets/images/babylon/box/girl1.jpeg',
  'assets/images/babylon/box/girl2.jpeg',
  'assets/images/babylon/box/girl3.jpeg',
  'assets/images/babylon/box/girl4.jpeg',
  'assets/images/babylon/box/girl5.jpeg',
  'assets/images/babylon/box/girl6.jpeg'
]

/**
 * 生成新的图片
 * 2 rows height => 800*2
 * 3 columns width => 800*3
 */
const filename = `${targetPath}/girls.jpeg`
const gm = GM.subClass({ imageMagick: '7+' })
// 创建一张空图片
gm(800*3, 800*2, '#ffffffff')
.draw(`image Over 0, 0, 800, 800, '${images[0]}'`)
.draw(`image Over 800, 0, 800, 800, '${images[1]}'`)
.draw(`image Over 1600, 0, 800, 800, '${images[2]}'`)
.draw(`image Over 0, 800, 800, 800, '${images[3]}'`)
.draw(`image Over 800, 800, 800, 800, '${images[4]}'`)
.draw(`image Over 1600, 800, 800, 800, '${images[5]}'`)
.write(filename, (error) => {
  console.info(error)
})